package org.rsbot.script.internal.wrappers;

import org.rsbot.client.StatusNode;
import org.rsbot.client.StatusNodeList;

public class StatusQueue
{
  private final StatusNodeList nl;
  private StatusNode c_node;

  public StatusQueue(StatusNodeList paramStatusNodeList)
  {
    this.nl = paramStatusNodeList;
  }

  public StatusNode getFirst() {
    StatusNode localStatusNode = this.nl.getHead().getNext();

    if (localStatusNode == this.nl.getHead()) {
      this.c_node = null;
      return null;
    }
    this.c_node = localStatusNode.getNext();

    return localStatusNode;
  }

  public StatusNode getLast() {
    StatusNode localStatusNode = this.nl.getHead().getPrevious();

    if (localStatusNode == this.nl.getHead()) {
      this.c_node = null;
      return null;
    }
    this.c_node = localStatusNode.getPrevious();

    return localStatusNode;
  }

  public StatusNode getNext() {
    StatusNode localStatusNode = this.c_node;

    if ((localStatusNode == this.nl.getHead()) || (localStatusNode == null)) {
      this.c_node = null;
      return null;
    }
    this.c_node = localStatusNode.getNext();

    return localStatusNode;
  }

  public StatusNode getPrevious() {
    StatusNode localStatusNode = this.c_node;

    if ((localStatusNode == this.nl.getHead()) || (localStatusNode == null)) {
      this.c_node = null;
      return null;
    }
    this.c_node = localStatusNode.getNext();

    return localStatusNode;
  }

  public int size() {
    int i = 0;
    StatusNode localStatusNode = this.nl.getHead().getPrevious();

    while (localStatusNode != this.nl.getHead()) {
      localStatusNode = localStatusNode.getPrevious();
      i++;
    }

    return i;
  }
}